package com.cj.io;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * ClassName: Calculator <br/>
 * Function: 计算工具类 <br/>
 * date: 2018/05/09 11:10 <br/>
 *
 * @author chenj
 * @version 1.0.0
 * @since JDK 1.8
 */
public final class Calculator {

    private final static ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");

    public static Object cal(String expression) throws ScriptException {
        return jse.eval(expression);
    }
}
